###猜大小游戏###
import random

i = 0
jindou = 100
# 统计玩的次数cishu
cishu = 0
win_cishu = 0
lingpai = 0
while i == 0:
    dice1 = random.randint(1, 6)
    dice2 = random.randint(1, 6)
    dice3 = random.randint(1, 6)
    sumu = dice1 + dice2 + dice3
    cishu += 1
    a = input("请输入大或者小：")
    #基本功能实现
    if 3 <= sumu <= 10:
        result = "小"
    else:
        result = "大"
    if a == result:
        # if a == b:
            jindou += 100
            win_cishu += 1
            print(f"恭喜你猜中了，获得金豆100，您的当前金豆数：{jindou}您目前已经玩了{cishu}次了,当前胜率：{(win_cishu / cishu) * 100}%")
    else:
            jindou -= 100
            print(f"恭喜你猜错了，输掉金豆100，您的当前金豆数：{jindou},(注意：金豆低于100将限制您的功能)，您目前已经玩了{cishu}次了,当前胜率：{(win_cishu / cishu) * 100}%")
            #令牌功能实现
            if lingpai > 0 :
                lingpai_do = input("检测到您拥有免错令牌，是否使用令牌免除当前错误，使用之后，此次不减少金豆，且不扣除胜率")
                if lingpai_do == "是":
                    jindou += 100
                    cishu -= 1
                    lingpai_do -= 1
                    print(f"使用成功,你的当前胜率为{(win_cishu / cishu) * 100}%")
                elif lingpai_do == "否":
                    pass
                else:
                    print("请不要输入不相关的东西")
            else:
                pass
    # else:
    #     b = "大"
    #     if a == b:
    #         jindou += 100
    #         win_cishu += 1
    #         print(f"恭喜你猜中了，获得金豆100，您的当前金豆数：{jindou}您目前已经玩了{cishu}次了,当前胜率：{(win_cishu / cishu) * 100}%")
    #     else:
    #         jindou -= 100
    #         print(f"恭喜你猜错了，输掉金豆100，您的当前金豆数：{jindou},(注意：金豆低于100将限制您的功能)，您目前已经玩了{cishu}次了,当前胜率：{(win_cishu / cishu) * 100}%")
    #         if lingpai > 0:
    #             lingpai_do = input("检测到您拥有免错令牌，是否使用令牌免除当前错误，使用之后，此次不减少金豆，且不扣除胜率")
    #             if lingpai_do == "是":
    #                 jindou += 100
    #                 cishu -= 1
    #                 lingpai_do -= 1
    #                 print(f"使用成功,你的当前胜率为{(win_cishu / cishu) * 100}%")
    #             elif lingpai_do == "否":
    #                 pass
    #             else:
    #                 print("请不要输入不相关的东西")
    #         else:
    #             pass
    #金豆小于100且充值功能实现
    if jindou <= 100:
        chongzhi = input("不好意思，你的金豆数目太少了，请输入充值获得金豆（目前可选金额：648：10000金豆，328：5000金豆），注：充值可获得免错令牌（免错令牌可以使本次猜错结果不计算入内）：")
        if chongzhi == "充值":
            jine = input("请输入充值金额：")
            if jine == "648":
                jindou = jindou + 10000
                lingpai += 2
                print(f"充值成功，您的当前金豆为{jindou}，当前免错令牌{lingpai}")
            elif jine == "328":
                jindou = jindou + 5000
                print(f"充值成功，您的当前金豆为{jindou},当前免错令牌{lingpai}")
                lingpai += 1
            else:
                print("请不要输入不相关的东西")
                break
        else:
            print("由于您没有选择充值，且你的金豆数量过少，系统将直接退出")
            break
    else:
        pass
    #退出游戏功能实现
    panduan = input("您可以输入exit退出，或者输入任意值继续玩")
    if panduan == "exit":
        print(f"你已经玩了{cishu}把,胜率：{(win_cishu / cishu) / 100}%")
        break
